<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ddiir">
    <meta name="keyword" content="databases,experiments">
    <link rel="shortcut icon" href="/rucdbcourse/views/images/ruc_logo_icon.jpg">
    <title>数据库系统概论实验评分系统</title>
    <!-- Bootstrap core CSS -->
    <link href="/rucdbcourse/views/css/bootstrap.min.css" rel="stylesheet">
    <link href="/rucdbcourse/views/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="/rucdbcourse/views/assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <!-- Custom styles for this viewPage -->
    <link href="/rucdbcourse/views/css/style-login.css" rel="stylesheet">
    <link href="/rucdbcourse/views/css/style-responsive.css" rel="stylesheet" />
    <link href="/rucdbcourse/views/assets/layer/skin/layer.css" rel="stylesheet" />
    <!-- jQuery -->
    <script type="text/javascript" src="/rucdbcourse/views/js/jquery.js"></script>
    <script type="text/javascript" src="/rucdbcourse/views/lib/angular.min.js"></script>
    <!-- Page walkthrough plugin -->
    <script type="text/javascript" src="/rucdbcourse/views/js/vCode.js"></script>
    <script>
    </script>
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
    <script src="views/js/html5shiv.js"></script>
    <script src="views/js/respond.min.js"></script>
    <![endif]-->
</head>

<body class="login-body">
    <!-- 页面加载时遮罩层 -->
    <div id="mask" style=" position: absolute; top: 0; left: 0; width: 100%; height: 100%;background-color:rgba(0,0,0,0.3);z-index:9999"></div>
    <!-- 遮罩层结束 -->
    <!-- 顶栏 -->

    <div class="header">
        <img src="/rucdbcourse/views/images/ruc_logo.png" class="header-pic"> 
        <!-- <button class="btn" onClick="javascript:window.location.href='/rucdbcourse/'" style="margin-left:950px;margin-top:5px">学生登录</button> -->
    </div>
    <!-- 顶栏结束 -->
    <!-- 页面主体 -->
    <div class="container">
        <div class="login_pictures">
            <div id="login-bg" class="login_pictures_picture" style="top:80px;margin-left:10px;height:550px"></div>
            <div class="login_pictures_txt" id="login-txt-block">
                <p class="login_pictures_title">亲爱的老师，您好！</p>
                <p id="login-txt"></p>
            </div>
        </div>
        <div class="form-signin" ng-app="signin" ng-controller="signinCtrl">
            <h2 class="form-signin-heading">账号登录</h2>
            <div class="login-wrap">
                <input type="text" ng-model="teacherid" id="uid" name="userid" class="form-control" placeholder="请输入账号" autofocus>
                <input type="password" ng-model="passwd" name="password" id="upsw" class="form-control" placeholder="请输入密码">
                <input style="float:left;width:40%;vertical-align:middle;" type="text" ng-model="verifycode" name="veryCode" id="veryCode" class="form-control" placeholder="验证码">
                <div id="vCode1" style="width:100px; height: 46px; margin-left: 20px;margin-top: 11px; border: 1px solid #ccc; display: inline-block;"></div>
                <button class="btn btn-lg btn-login btn-block" ng-click="submits()" id="login-btn">登&nbsp;&nbsp;&nbsp;&nbsp;录</button>
            </div>
        </div>
    </div>
    <!-- 页面主体结束 -->
    <!-- 页脚 -->
    <div class="footer">
        <div class="container">
            Copyright &copy;2005-2017 ruc.edu.cn v1.0 All Rights Reserved. 京ICP备05066828号-1
            <br>
        </div>
    </div>
    <!-- 页脚结束 -->
    <script src="/rucdbcourse/views/assets/layer/layer.js"></script>
    <script type="text/javascript" src="/rucdbcourse/views/js/verifyCode.js"></script>
    <script>
    //捕获键盘点击事件
    $(function() {
        document.onkeydown = function(e) {
            var ev = document.all ? window.event : e;
            if (ev.keyCode == 13) {
                $("#login-btn").click();
            }
        }
    });


    var app = angular.module('signin', []);
    app.controller('signinCtrl', function($scope, $http) {

    	//验证码
        var container1 = document.getElementById("vCode1");
        var code1 = new vCode(container1);
        $scope.submits = function() {
            if ($scope.teacherid == null) {
                layer.msg('用户名不能为空');
                return false;
            } else if ($scope.passwd == null) {
                layer.msg('密码不能为空！');
                return false;
            } else if ($scope.verifycode == null) {
                layer.msg('请填写验证码');
                return false;
            } else if(!code1.verify(document.getElementById("veryCode").value)){
            	layer.msg('验证码错误');
            	return false; 	
            }else{
                $("#login-btn").attr("disabled", true);
                $("#login-btn").html("登录中...");
                $http.post('../user/tlogin',
                        $.param({
                            teacherid: $scope.teacherid,
                            passwd: $scope.passwd
                        }), {
                            headers: {
                                'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
                            }
                        })
                    .then(function(response) {
                        //debugger
                        // console.log(response.data.value)
                        var result = response.data.value
                        if (result == 'success') {
                            //debugger
                            // console.log(response.data.value);
                            $("#login-btn").attr("disabled", false);
                            $("#login-btn").html("登&nbsp;&nbsp;&nbsp;&nbsp;录");
                            window.location = "tindex.html";
                        } else {
                            result = result == "passwd_err" ? "密码错误" : "用户不存在";
                            layer.msg(result)
                            // console.log(response.data.msg);
                            $("#login-btn").attr("disabled", false);
                            $("#login-btn").html("登&nbsp;&nbsp;&nbsp;&nbsp;录");
                        }
                    });
            }
        };
    });
    </script>
    <script type="text/javascript">
    //页面加载时显示遮罩层
    window.onload = function() {
        $("#mask").css("display", "none");
    }
    var url;

    $(document).ready(function() {
        var randomNum = Math.random() * 5;
        //var r=Math.ceil(randomNum);
        var r = 5;
        document.getElementById("login-txt").innerHTML = "绿野堂开占物华，<br/>路人指道令公家。<br/>令公桃李满天下，<br/>何用堂前更种花。<br/>——《奉和令公绿野堂种花》 唐·白居易";
        if (r == 1) {
            document.getElementById("login-bg").style.backgroundImage = "url(/rucdbcourse/views/images/bg1.jpg)";
            document.getElementById("login-txt-block").style.paddingLeft = "400px";
        } else if (r == 2) {
            document.getElementById("login-bg").style.backgroundImage = "url(/rucdbcourse/views/images/bg2.jpg)";
            document.getElementById("login-txt-block").style.paddingLeft = "300px";
        } else if (r == 3) {
            document.getElementById("login-bg").style.backgroundImage = "url(/rucdbcourse/views/images/bg3.jpg)";
            document.getElementById("login-txt-block").style.paddingLeft = "0px";
        } else if (r == 4) {
            document.getElementById("login-bg").style.backgroundImage = "url(/rucdbcourse/views/images/bg4.jpg)";
            document.getElementById("login-txt-block").style.paddingLeft = "10px";
        } else if (r == 5) {
            document.getElementById("login-bg").style.backgroundImage = "url(/rucdbcourse/views/images/bg7.png)";
            document.getElementById("login-txt-block").style.paddingLeft = "10px";
        } else if (r == 6) {
            document.getElementById("login-bg").style.backgroundImage = "url(/rucdbcourse/views/images/bg6.png)";
            document.getElementById("login-txt-block").style.paddingLeft = "50px";
        }
    });
    </script>
</body>

</html>
